#ifndef __FILE_MANAGER_H__
#define __FILE_MANAGER_H__

#include <opencv2/opencv.hpp>

struct ImgInfo {
    cv::Size imgSize;
    int imgByte;
    int imgPix;
};

class FileManager {
private:
    static const ImgInfo imgInfo4K_;
    static const ImgInfo imgInfo2K_;

    ImgInfo imgInfo_;

private:
    int getFileSize(const char* filename, uintmax_t& fileSize) const;
    int checkBinning(const char *filename);
    int checkFileType(const char *filename) const;

    int rawToImg(const char *filename, ushort*& data, cv::Mat& img);
    int fitsToImg(const char *filename, ushort*& data, cv::Mat& img);

public:
    FileManager() : imgInfo_(imgInfo4K_) {}
    int convertTo16BitImg(const char *filename, ushort*& data, cv::Mat& img);
    int convertToRaw(const cv::Mat& img, const char *filename) const;
    int convertToFits(float exp, int gain, int binning, float ra, float dec, const char *object, const char *dateOBS, const cv::Mat& imgRaw, const char *filename) const;
    int convertToFits(const cv::Mat& imgSrc, const char *filename) const;
    int convertToColorFits(const cv::Mat& imgSrc, const char *filename) const;
    int convertToFitsFromFile(const char *filename) const;
};


#endif